<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"
	import="database.RaavareDTO, database.MySQLRaavareDAO, java.util.ArrayList"%>

<%
	request.setAttribute("title", "Create rawbatch");
%>

<%
	MySQLRaavareDAO raavareDAO;
	ArrayList<RaavareDTO> raavareList = new ArrayList<RaavareDTO>();
	raavareDAO = new MySQLRaavareDAO();
	raavareList = raavareDAO.getRaavareList();
%>

<%@include file="/WEB-INF/html/header.jsp"%>

<h1>Make new Raw batch:</h1>
<br>

<%
	ArrayList<String[]> errors = (ArrayList<String[]>) request.getAttribute("errors");
%>
<br>
<%
	if (errors != null) {
		for (int i = 0; i < errors.size(); i++) {
			if (errors.get(i)[2] != null) {
				out.println("<b>" + errors.get(i)[0] + "</b>&nbsp;");
				out.println(errors.get(i)[2] + "&nbsp;");
				out.println("<br />");
			}	
		}
	} else
		out.println(" ");

	if (request.getAttribute("succes") != null) {
		out.println(request.getAttribute("succes").toString());
	}
%>

<br>

<form method="POST"
	action="<%out.print(request.getContextPath());%>/Rawbatch">

	<table>
		<tr>
			<td>Please enter expiration date :</td>
			<td><input type="text" name="udloebsdato"></td><td><p style="color:#C0C0C0">"yyyy-MM-dd"</p></td>
		</tr>
		<tr>
			<td>Please enter amount:</td>
			<td><input type="text" name="maengde"></td><td><p style="color:#C0C0C0">"double"</p></td>
		</tr>
		<tr>
			<td>Please enter raavareId:</td>
			<td><select name="raavareId">
					<%
						for (int i = 0; i < raavareList.size(); i++) {
							out.print("<option value=\""
									+ raavareList.get(i).getRaavareId() + "\">");
							out.print(raavareList.get(i).getRaavareId() + " "
									+ raavareList.get(i).getRaavareNavn());
							out.print("</option>");
						}
					%>
			</select></td>
		</tr>
		<tr>
			<td></td>
			<td><input type="submit" name="newBatch" value="Create"></td>
		</tr>
	</table>


</form>

<%@include file="/WEB-INF/html/footer.jsp"%>

